<template>
	<view>
		<view class="contributionHead">
			<view class="detailNaver">
				<view @click="backTo" class="backMytask"><image src="/static/images/back.png"></image></view>
				<view class="status">贡献值</view>
				<view></view>
			</view>
			<view class="contributionBody">
				<view class="bodyTop">当前贡献值</view>
				<view class="bodyCenter">
					<text>{{ number }}</text>
					<text>贡献值</text>
				</view>
				<view class="bodyBtm">您已获得{{ number }}元贡献值</view>
			</view>
		</view>

		<view class="contributionNaver">
			<view @click="getcontriList(index)" v-for="(item, index) in list" :key="index" :class="{ naverItem: showStyle == index }">{{ item.text }}</view>
		</view>

		<scroll-view @scrolltolower="uploadMissioc" :style="'height:' + wh + 'px'" scroll-y="true" class="scroll">
			<view class="contriList">
				<view v-for="(item, index) in contributionList" :key="index" class="item">
					<view class="itemLeft">
						<view class="leftImg"><image src="/static/images/issueImg.png"></image></view>
						<view class="leftFont">
							<view class="leftTop">{{ item.mark }}</view>
							<view class="leftBtm">{{ item.create_time }}</view>
						</view>
					</view>
					<view class="itemRight">
						<text>贡献值</text>
						<text v-if="item.pm == 0">-</text>
						<text v-else>+</text>
						<text>{{ item.number }}</text>
					</view>
				</view>
			</view>

			<view v-if="!contributionList.length" class="notAvailable">暂无明细~</view>
		</scroll-view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			list: [
				{
					text: '领取任务'
				},
				{
					text: '推广'
				}
			],
			showStyle: 0,
			wh: '',
			number: '',
			type: 'task',
			contributionList: []
		};
	},
	onLoad(e) {
		// 获取设备的高度
		let that = this;
		uni.getSystemInfo({
			success: function(res) {
				that.wh = res.windowHeight - 295;
			}
		});
		that.number = e.num;
		that.getContribution();
	},
	methods: {
		// 获取贡献值
		getContribution() {
			this.$api.getUserContribution(
				{
					type: this.type
				},
				res => {
					this.contributionList = res.data;
				}
			);
		},
		// 返回
		backTo() {
			uni.navigateBack();
		},

		// 切换导航栏
		getcontriList(index) {
			this.showStyle = index;
			if (index == 0) {
				this.type = 'task';
			} else {
				this.type = 'recommend';
			}
			this.getContribution();
		},
		// 滚动到底部加载任务数据
		uploadMissioc() {}
	}
};
</script>

<style lang="less">
.contributionHead {
	height: 470rpx;
	background: url(../../../static/images/background13.png) no-repeat;
	background-size: 100% 100%;
	padding: 0 30rpx;
	background-color: #ffffff;
	.detailNaver {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 88rpx;
		margin-bottom: 40rpx;
		.backMytask {
			width: 20rpx;
			height: 35rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
		.status {
			font-size: 35rpx;
			color: #ffffff;
		}
	}
	.contributionBody {
		font-size: 28rpx;
		color: #ffffff;
		.bodyCenter {
			margin: 25rpx 0;
			text:nth-child(1) {
				font-size: 86rpx;
			}
		}
	}
}

.contributionNaver {
	display: flex;
	justify-content: space-around;
	align-items: center;
	height: 100rpx;
	background-color: #ffffff;
	margin-bottom: 20rpx;
	font-size: 36rpx;
	color: #999999;
	.naverItem {
		position: relative;
		color: #b59467;
	}
	.naverItem::before {
		content: '';
		position: absolute;
		bottom: -28rpx;
		left: 50%;
		background-color: #b59467;
		width: 80rpx;
		height: 4rpx;
		transform: translateX(-50%);
	}
}

.scroll {
	.contriList {
		overflow: hidden;
		background-color: #ffffff;
		.item:last-child {
			border-bottom: none;
		}
		.item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 30rpx;
			height: 120rpx;
			border-bottom: 1rpx solid #e5e5e5;
			.itemLeft {
				display: flex;
				justify-content: space-between;
				align-items: center;
				.leftImg {
					width: 65rpx;
					height: 65rpx;
					margin-right: 15rpx;
					image {
						width: 100%;
						height: 100%;
					}
				}
				.leftFont {
					.leftTop {
						font-size: 28rpx;
						font-weight: bold;
						color: #333333;
					}
					.leftBtm {
						font-size: 20rpx;
						color: #999999;
					}
				}
			}
			.itemRight {
				background: linear-gradient(-70deg, #ff743f, #f6b34a);
				border-radius: 25rpx;
				text-align: center;
				color: #ffffff;
				font-size: 24rpx;
				padding: 10rpx 25rpx;
			}
		}
	}
	.notAvailable {
		width: 100%;
		height: 150rpx;
		text-align: center;
		line-height: 200rpx;
		font-size: 24rpx;
		color: #666;
		margin-top: 200rpx;
	}
}
</style>
